<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Introduction - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.gdata.introduction.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.gdata.introduction.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.gdata.html">Zend_Gdata</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.gdata.authsub.html">Authenticating with AuthSub</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.gdata.introduction" class="section"><div class="info"><h1 class="title">Introduction</h1></div>
    

    <p class="para">
        Google Data <acronym class="acronym">API</acronym>s provide programmatic interface to some of Google&#039;s
        online services. The Google data Protocol is based upon the <a href="http://ietfreport.isoc.org/idref/draft-ietf-atompub-protocol/" class="link external">&raquo; Atom Publishing
            Protocol</a> and allows client applications to retrieve data matching queries,
        post data, update data and delete data using standard <acronym class="acronym">HTTP</acronym> and the
        Atom syndication formation. The <span class="classname">Zend_Gdata</span> component is a
        <acronym class="acronym">PHP</acronym> 5 interface for accessing Google Data from <acronym class="acronym">PHP</acronym>.
        The <span class="classname">Zend_Gdata</span> component also supports accessing other services
        implementing the Atom Publishing Protocol.
    </p>

    <p class="para">
        See
        <a href="http://code.google.com/apis/gdata/" class="link external">&raquo; http://code.google.com/apis/gdata/</a>
        for more information about Google Data <acronym class="acronym">API</acronym>.
    </p>

    <p class="para">
        The services that are accessible by <span class="classname">Zend_Gdata</span> include the
        following:

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.calendar.html" class="link">Google Calendar</a>
                    is a popular online calendar application.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.spreadsheets.html" class="link">Google Spreadsheets</a>
                    provides an online collaborative spreadsheets tool which
                    can be used as a simple data store for your applications.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.docs.html" class="link">Google Documents List</a>
                    provides an online list of all spreadsheets, word processing documents,
                    and presentations stored in a Google account.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.gapps.html" class="link">Google Provisioning</a>
                    provides the ability to create, retrieve, update, and
                    delete user accounts, nicknames, groups, and email lists on a
                    Google Apps hosted domain.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.gbase.html" class="link">Google Base</a>
                    provides the ability to retrieve, post, update, and
                    delete items in Google Base.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.youtube.html" class="link">YouTube</a>
                    provides the ability to search and retrieve videos,
                    comments, favorites, subscriptions, user profiles
                    and more.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="zend.gdata.photos.html" class="link">Picasa Web Albums</a>
                    provides an online photo sharing application.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <a href="http://code.google.com/apis/blogger/developers_guide_php.html" class="link external">&raquo; Google
                        Blogger</a> is a popular Internet provider of
                    &quot;push-button publishing&quot; and syndication.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    Google CodeSearch
                    allows you to search public source code from many projects.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    Google Notebook
                    allows you to view public Notebook content.
                </p>
            </li>
        </ul>
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Unsupported services</b><br /></span>
        

        <p class="para">
            <span class="classname">Zend_Gdata</span> does not provide an interface to any other Google
            service, such as Search, Gmail, Translation, or Maps.
            Only services that support the Google Data <acronym class="acronym">API</acronym> are supported.
        </p>
    </p></blockquote>

    <div class="section" id="zend.gdata.introduction.structure"><div class="info"><h1 class="title">Structure of Zend_Gdata</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Gata</span> is composed of several types of classes:

            <ul class="itemizedlist">
                <li class="listitem">
                    <p class="para">
                        Service classes - inheriting from <span class="classname">Zend_Gdata_App</span>.
                        These also include other classes such as <span class="classname">Zend_Gdata</span>,
                        <span class="classname">Zend_Gdata_Spreadsheets</span>, etc. These classes enable
                        interacting with APP or GData services and provide the
                        ability to retrieve feeds, retrieve entries, post
                        entries, update entries and delete entries.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Query classes - inheriting from <span class="classname">Zend_Gdata_Query</span>.
                        These also include other classes for specific services,
                        such as <span class="classname">Zend_Gdata_Spreadsheets_ListQuery</span> and
                        <span class="classname">Zend_Gdata_Spreadsheets_CellQuery</span>. Query classes
                        provide methods used to construct a query for data
                        to be retrieved from GData services. Methods include
                        getters and setters like  <span class="methodname">setUpdatedMin()</span>,
                         <span class="methodname">setStartIndex()</span>, and
                         <span class="methodname">getPublishedMin()</span>. The query classes also
                        have a method to generate a <acronym class="acronym">URL</acronym> representing the
                        constructed query --  <span class="methodname">getQueryUrl()</span>.
                        Alternatively, the query string component of the <acronym class="acronym">URL</acronym>
                        can be retrieved used the  <span class="methodname">getQueryString()</span>
                        method.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Feed classes - inheriting from <span class="classname">Zend_Gdata_App_Feed</span>.
                        These also include other classes such as
                        <span class="classname">Zend_Gdata_Feed</span>,
                        <span class="classname">Zend_Gdata_Spreadsheets_SpreadsheetFeed</span>,
                        and <span class="classname">Zend_Gdata_Spreadsheets_ListFeed</span>.
                        These classes represent feeds of entries retrieved
                        from services. They are primarily used to retrieve
                        data returned from services.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Entry classes - inheriting from <span class="classname">Zend_Gdata_App_Entry</span>.
                        These also include other classes such as
                        <span class="classname">Zend_Gdata_Entry</span>, and
                        <span class="classname">Zend_Gdata_Spreadsheets_ListEntry</span>.
                        These classes represent entries retrieved from
                        services or used for constructing data to send to
                        services. In addition to being able to set the
                        properties of an entry (such as the spreadsheet cell
                        value), you can use an entry object to send update
                        or delete requests to a service. For example,
                        you can call <strong class="command">$entry-&gt;save()</strong> to save
                        changes made to an entry back to service from which
                        the entry initiated, or <strong class="command">$entry-&gt;delete()</strong>
                        to delete an entry from the server.
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Other Data model classes - inheriting from
                        <span class="classname">Zend_Gdata_App_Extension</span>. These include classes such
                        as <span class="classname">Zend_Gdata_App_Extension_Title</span> (representing the
                        atom:title <acronym class="acronym">XML</acronym> element),
                        <span class="classname">Zend_Gdata_Extension_When</span>
                        (representing the gd:when <acronym class="acronym">XML</acronym> element used by the
                        GData Event &quot;Kind&quot;), and
                        <span class="classname">Zend_Gdata_Extension_Cell</span> (representing the gs:cell
                        <acronym class="acronym">XML</acronym> element used by Google Spreadsheets). These
                        classes are used purely to store the data retrieved
                        back from services and for constructing data to be
                        sent to services. These include getters and setters
                        such as
                         <span class="methodname">setText()</span> to set the child text
                        node of an element,  <span class="methodname">getText()</span> to retrieve
                        the text node of an element,  <span class="methodname">getStartTime()</span>
                        to retrieve the start time attribute of a When element,
                        and other similiar methods.
                        The data model classes also include methods such as
                         <span class="methodname">getDOM()</span> to retrieve a DOM representation
                        of the element and all children and
                         <span class="methodname">transferFromDOM()</span> to construct a data
                        model representation of a DOM tree.
                    </p>
                </li>
            </ul>
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.services"><div class="info"><h1 class="title">Interacting with Google Services</h1></div>
        

        <p class="para">
            Google data services are based upon the Atom Publishing Protocol
            (APP) and the Atom syndication format. To interact with APP or
            Google services using the <span class="classname">Zend_Gdata</span> component, you need to use
            the service classes such as <span class="classname">Zend_Gdata_App</span>,
            <span class="classname">Zend_Gdata</span>, <span class="classname">Zend_Gdata_Spreadsheets</span>, etc.
            These service classes provide methods to retrieve data from services as feeds, insert
            new entries into feeds, update entries, and delete entries.
        </p>

        <p class="para">
            Note: A full example of working with <span class="classname">Zend_Gdata</span> is available in
            the <var class="filename">demos/Zend/Gdata</var> directory. This example is runnable
            from the command-line, but the methods contained within are easily
            portable to a web application.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.magicfactory"><div class="info"><h1 class="title">Obtaining instances of Zend_Gdata classes</h1></div>
        

        <p class="para">
            The Zend Framework naming standards require that all classes be
            named based upon the directory structure in which they are located.
            For instance, extensions related to Spreadsheets are stored in:
            <var class="filename">Zend/Gdata/Spreadsheets/Extension/...</var> and, as a result
            of this, are named
            <span class="classname">Zend_Gdata_Spreadsheets_Extension_...</span>.
            This causes a lot of typing if you&#039;re trying to construct a new
            instance of a spreadsheet cell element!
        </p>

        <p class="para">
            We&#039;ve implemented a magic factory method in all service classes
            (such as <span class="classname">Zend_Gdata_App</span>, <span class="classname">Zend_Gdata</span>,
            <span class="classname">Zend_Gdata_Spreadsheets</span>) that should make constructing new
            instances of data model, query and other classes much easier. This magic factory is
            implemented by using the magic  <span class="methodname">__call()</span> method to intercept all
            attempts to call <strong class="command">$service-&gt;newXXX(arg1, arg2, ...)</strong>. Based off
            the value of XXX, a search is performed in all registered &#039;packages&#039;
            for the desired class. Here&#039;s some examples:
        </p>

        <pre class="programlisting brush: php">
$ss = new Zend_Gdata_Spreadsheets();

// creates a Zend_Gdata_App_Spreadsheets_CellEntry
$entry = $ss-&gt;newCellEntry();

// creates a Zend_Gdata_App_Spreadsheets_Extension_Cell
$cell = $ss-&gt;newCell();
$cell-&gt;setText(&#039;My cell value&#039;);
$cell-&gt;setRow(&#039;1&#039;);
$cell-&gt;setColumn(&#039;3&#039;);
$entry-&gt;cell = $cell;

// ... $entry can then be used to send an update to a Google Spreadsheet
</pre>


        <p class="para">
            Each service class in the inheritance tree is responsible for
            registering the appropriate &#039;packages&#039; (directories) which are to
            be searched when calling the magic factory method.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.authentication"><div class="info"><h1 class="title">Google Data Client Authentication</h1></div>
        

        <p class="para">
            Most Google Data services require client applications to
            authenticate against the Google server before accessing
            private data, or saving or deleting data.
            There are two implementations of authentication for Google Data:
            <a href="zend.gdata.authsub.html" class="link">AuthSub</a> and
            <a href="zend.gdata.clientlogin.html" class="link">ClientLogin</a>.
            <span class="classname">Zend_Gdata</span> offers class interfaces for both of these methods.
        </p>

        <p class="para">
            Most other types of queries against Google Data services do not
            require authentication.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.dependencies"><div class="info"><h1 class="title">Dependencies</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Gdata</span> makes use of
            <a href="zend.http.client.html" class="link">Zend_Http_Client</a> to send
            requests to google.com and fetch results. The response to most
            Google Data requests is returned as a subclass of the
            <span class="classname">Zend_Gdata_App_Feed</span> or
            <span class="classname">Zend_Gdata_App_Entry</span> classes.
        </p>

        <p class="para">
            <span class="classname">Zend_Gdata</span> assumes your <acronym class="acronym">PHP</acronym> application is
            running on a host that has a direct connection to the Internet.
            The <span class="classname">Zend_Gdata</span> client operates by contacting Google Data servers.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.creation"><div class="info"><h1 class="title">Creating a new Gdata client</h1></div>
        

        <p class="para">
            Create a new object of class <span class="classname">Zend_Gdata_App</span>,
            <span class="classname">Zend_Gdata</span>, or one of the subclasses available that offer helper
            methods for service-specific behavior.
        </p>

        <p class="para">
            The single optional parameter to the <span class="classname">Zend_Gdata_App</span> constructor
            is an instance of
            <a href="zend.http.client.html" class="link">Zend_Http_Client</a>.
            If you don&#039;t pass this parameter, <span class="classname">Zend_Gdata</span> creates a default
            <span class="classname">Zend_Http_Client</span> object, which will not have associated
            credentials to access private feeds. Specifying the
            <span class="classname">Zend_Http_Client</span> object also allows you to
            pass configuration options to that client object.
        </p>

        <pre class="programlisting brush: php">
$client = new Zend_Http_Client();
$client-&gt;setConfig( ...options... );

$gdata = new Zend_Gdata($client);
</pre>


        <p class="para">
            Beginning with Zend Framework 1.7, support has been added for
            protocol versioning. This allows the client and server to support
            new features while maintaining backwards compatibility. While most
            services will manage this for you, if you create a <span class="classname">Zend_Gdata</span>
            instance directly (as opposed to one of its subclasses), you may
            need to specify the desired protocol version to access certain
            server functionality.
        </p>

        <pre class="programlisting brush: php">
$client = new Zend_Http_Client();
$client-&gt;setConfig( ...options... );

$gdata = new Zend_Gdata($client);
$gdata-&gt;setMajorProtocolVersion(2);
$gdata-&gt;setMinorProtocolVersion(null);
</pre>


        <p class="para">
            Also see the sections on authentication for methods to
            create an authenticated <span class="classname">Zend_Http_Client</span> object.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.parameters"><div class="info"><h1 class="title">Common Query Parameters</h1></div>
        

        <p class="para">
            You can specify parameters to customize queries with <span class="classname">Zend_Gdata</span>.
            Query parameters are specified using subclasses of
            <span class="classname">Zend_Gdata_Query</span>. The <span class="classname">Zend_Gdata_Query</span>
            class includes methods to set all query parameters used throughout GData services.
            Individual services, such as Spreadsheets, also provide query classes to defined
            parameters which are custom to the particular service and feeds.
            Spreadsheets includes a CellQuery class to query the Cell Feed
            and a ListQuery class to query the List Feed, as different
            query parameters are applicable to each of those feed types.

            The GData-wide parameters are described below.
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    The <span class="property">q</span> parameter specifies a full-text
                    query. The value of the parameter is a string.
                </p>

                <p class="para">
                    Set this parameter with the  <span class="methodname">setQuery()</span>
                    function.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The <span class="property">alt</span> parameter specifies the feed type.
                    The value of the parameter can be <span class="property">atom</span>,
                    <span class="property">rss</span>, <span class="property">json</span>,
                    or <span class="property">json-in-script</span>.
                    If you don&#039;t specify this parameter, the default feed type
                    is <span class="property">atom</span>. NOTE: Only the output of the
                    atom feed format can be processed using
                    <span class="classname">Zend_Gdata</span>.
                    The <span class="classname">Zend_Http_Client</span> could be used to retrieve
                    feeds in other formats, using query <acronym class="acronym">URL</acronym>s generated by the
                    <span class="classname">Zend_Gdata_Query</span> class and its subclasses.
                </p>

                <p class="para">
                    Set this parameter with the  <span class="methodname">setAlt()</span>
                    function.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The <span class="property">maxResults</span> parameter limits the number
                    of entries in the feed. The value of the parameter is
                    an integer. The number of entries returned in the feed
                    will not exceed this value.
                </p>

                <p class="para">
                    Set this parameter with the  <span class="methodname">setMaxResults()</span> function.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The <span class="property">startIndex</span> parameter specifies the
                    ordinal number of the first entry returned in the feed.
                    Entries before this number are skipped.
                </p>

                <p class="para">
                    Set this parameter with the  <span class="methodname">setStartIndex()</span>
                    function.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    The <span class="property">updatedMin</span> and <span class="property">updatedMax</span>
                    parameters specify bounds on the entry date.
                    If you specify a value for <span class="property">updatedMin</span>,
                    no entries that were updated earlier than the date
                    you specify are included in the feed. Likewise
                    no entries updated after the date specified by
                    <span class="property">updatedMax</span> are included.
                </p>

                <p class="para">
                    You can use numeric timestamps, or a variety of
                    date/time string representations as the value for
                    these parameters.
                </p>

                <p class="para">
                    Set this parameter with the  <span class="methodname">setUpdatedMin()</span>
                    and  <span class="methodname">setUpdatedMax()</span> functions.
                </p>
            </li>
        </ul>

        <p class="para">
            There is a  <span class="methodname">get*()</span> function for each
             <span class="methodname">set*()</span> function.
        </p>

        <pre class="programlisting brush: php">
$query = new Zend_Gdata_Query();
$query-&gt;setMaxResults(10);
echo $query-&gt;getMaxResults();   // returns 10
</pre>


        <p class="para">
            The <span class="classname">Zend_Gdata</span> class also implements &quot;magic&quot; getter and
            setter methods, so you can use the name of the parameter
            as a virtual member of the class.
        </p>

        <pre class="programlisting brush: php">
$query = new Zend_Gdata_Query();
$query-&gt;maxResults = 10;
echo $query-&gt;maxResults;        // returns 10
</pre>


        <p class="para">
            You can clear all parameters with the  <span class="methodname">resetParameters()</span>
            function. This is useful to do if you reuse a <span class="classname">Zend_Gdata</span>
            object for multiple queries.
        </p>

        <pre class="programlisting brush: php">
$query = new Zend_Gdata_Query();
$query-&gt;maxResults = 10;
// ...get feed...

$query-&gt;resetParameters();      // clears all parameters
// ...get a different feed...
</pre>

    </div>

    <div class="section" id="zend.gdata.introduction.getfeed"><div class="info"><h1 class="title">Fetching a Feed</h1></div>
        

        <p class="para">
            Use the  <span class="methodname">getFeed()</span> function to retrieve
            a feed from a specified <acronym class="acronym">URI</acronym>.
            This function returns an instance of class specified
            as the second argument to getFeed, which defaults to
            <span class="classname">Zend_Gdata_Feed</span>.
        </p>

        <pre class="programlisting brush: php">
$gdata = new Zend_Gdata();
$query = new Zend_Gdata_Query(
        &#039;http://www.blogger.com/feeds/blogID/posts/default&#039;);
$query-&gt;setMaxResults(10);
$feed = $gdata-&gt;getFeed($query);
</pre>


        <p class="para">
            See later sections for special functions in each
            helper class for Google Data services. These
            functions help you to get feeds from the <acronym class="acronym">URI</acronym> that is
            appropriate for the respective service.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.paging"><div class="info"><h1 class="title">Working with Multi-page Feeds</h1></div>
        

        <p class="para">
            When retrieving a feed that contains a large number of entries,
            the feed may be broken up into many smaller &quot;pages&quot; of feeds. When
            this occurs, each page will contain a link to the next page in the
            series. This link can be accessed by calling
             <span class="methodname">getLink(&#039;next&#039;)</span>. The following example shows how to
            retrieve the next page of a feed:
        </p>

        <pre class="programlisting brush: php">
function getNextPage($feed) {
    $nextURL = $feed-&gt;getLink(&#039;next&#039;);
    if ($nextURL !== null) {
        return $gdata-&gt;getFeed($nextURL);
    } else {
        return null;
    }
}
</pre>


        <p class="para">
            If you would prefer not to work with pages in your application,
            pass the first page of the feed into
             <span class="methodname">Zend_Gdata_App::retrieveAllEntriesForFeed()</span>, which
            will consolidate all entries from each page into a single feed.
            This example shows how to use this function:
        </p>

        <pre class="programlisting brush: php">
$gdata = new Zend_Gdata();
$query = new Zend_Gdata_Query(
        &#039;http://www.blogger.com/feeds/blogID/posts/default&#039;);
$feed = $gdata-&gt;retrieveAllEntriesForFeed($gdata-&gt;getFeed($query));
</pre>


        <p class="para">
            Keep in mind when calling this function that it may take a long
            time to complete on large feeds. You may need to increase <acronym class="acronym">PHP</acronym>&#039;s
            execution time limit by calling  <span class="methodname">set_time_limit()</span>.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.usefeedentry"><div class="info"><h1 class="title">Working with Data in Feeds and Entries</h1></div>
        

        <p class="para">
            After retrieving a feed, you can read the data from the feed
            or the entries contained in the feed using either the accessors
            defined in each of the data model classes or the magic
            accessors. Here&#039;s an example:
        </p>

        <pre class="programlisting brush: php">
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$gdata = new Zend_Gdata($client);
$query = new Zend_Gdata_Query(
        &#039;http://www.blogger.com/feeds/blogID/posts/default&#039;);
$query-&gt;setMaxResults(10);
$feed = $gdata-&gt;getFeed($query);
foreach ($feed as $entry) {
    // using the magic accessor
    echo &#039;Title: &#039; . $entry-&gt;title-&gt;text;
    // using the defined accessors
    echo &#039;Content: &#039; . $entry-&gt;getContent()-&gt;getText();
}
</pre>

    </div>

    <div class="section" id="zend.gdata.introduction.updateentry"><div class="info"><h1 class="title">Updating Entries</h1></div>
        

        <p class="para">
            After retrieving an entry, you can update that entry and save
            changes back to the server. Here&#039;s an example:
        </p>

        <pre class="programlisting brush: php">
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$gdata = new Zend_Gdata($client);
$query = new Zend_Gdata_Query(
        &#039;http://www.blogger.com/feeds/blogID/posts/default&#039;);
$query-&gt;setMaxResults(10);
$feed = $gdata-&gt;getFeed($query);
foreach ($feed as $entry) {
    // update the title to append &#039;NEW&#039;
    echo &#039;Old Title: &#039; . $entry-&gt;title-&gt;text;
    $entry-&gt;title-&gt;text = $entry-&gt;title-&gt;text . &#039; NEW&#039;;

    // update the entry on the server
    $newEntry = $entry-&gt;save();
    echo &#039;New Title: &#039; . $newEntry-&gt;title-&gt;text;
}
</pre>

    </div>

    <div class="section" id="zend.gdata.introduction.post"><div class="info"><h1 class="title">Posting Entries to Google Servers</h1></div>
        

        <p class="para">
            The <span class="classname">Zend_Gdata</span> object has a function
             <span class="methodname">insertEntry()</span> with which you can upload data to save
            new entries to Google Data services.
        </p>

        <p class="para">
            You can use the data model classes for each service to construct
            the appropriate entry to post to Google&#039;s services. The
             <span class="methodname">insertEntry()</span> function will accept a child of
            <span class="classname">Zend_Gdata_App_Entry</span> as data to post to the service.
            The method returns a child of <span class="classname">Zend_Gdata_App_Entry</span>
            which represents the state of the entry as it was returned from
            the server.
        </p>

        <p class="para">
            Alternatively, you could construct the <acronym class="acronym">XML</acronym> structure for an entry
            as a string and pass the string to the  <span class="methodname">insertEntry()</span>
            function.
        </p>

        <pre class="programlisting brush: php">
$gdata = new Zend_Gdata($authenticatedHttpClient);

$entry = $gdata-&gt;newEntry();
$entry-&gt;title = $gdata-&gt;newTitle(&#039;Playing football at the park&#039;);
$content =
    $gdata-&gt;newContent(&#039;We will visit the park and play football&#039;);
$content-&gt;setType(&#039;text&#039;);
$entry-&gt;content = $content;

$entryResult = $gdata-&gt;insertEntry($entry,
        &#039;http://www.blogger.com/feeds/blogID/posts/default&#039;);

echo &#039;The &lt;id&gt; of the resulting entry is: &#039; . $entryResult-&gt;id-&gt;text;
</pre>


        <p class="para">
            To post entries, you must be using an authenticated
            <span class="classname">Zend_Http_Client</span> that you created using the
            <span class="classname">Zend_Gdata_AuthSub</span> or
            <span class="classname">Zend_Gdata_ClientLogin</span> classes.
        </p>
    </div>

    <div class="section" id="zend.gdata.introduction.delete"><div class="info"><h1 class="title">Deleting Entries on Google Servers</h1></div>
        

        <p class="para">
            Option 1: The <span class="classname">Zend_Gdata</span> object has a function
             <span class="methodname">delete()</span> with which you can delete entries from Google Data
            services. Pass the edit <acronym class="acronym">URL</acronym> value from
            a feed entry to the  <span class="methodname">delete()</span> method.
        </p>

        <p class="para">
            Option 2: Alternatively, you can call <strong class="command">$entry-&gt;delete()</strong>
            on an entry retrieved from a Google service.
        </p>

        <pre class="programlisting brush: php">
$gdata = new Zend_Gdata($authenticatedHttpClient);
// a Google Data feed
$feedUri = ...;
$feed = $gdata-&gt;getFeed($feedUri);
foreach ($feed as $feedEntry) {
    // Option 1 - delete the entry directly
    $feedEntry-&gt;delete();
    // Option 2 - delete the entry by passing the edit URL to
    // $gdata-&gt;delete()
    // $gdata-&gt;delete($feedEntry-&gt;getEditLink()-&gt;href);
}
</pre>


        <p class="para">
            To delete entries, you must be using an authenticated
            <span class="classname">Zend_Http_Client</span> that you created using the
            <span class="classname">Zend_Gdata_AuthSub</span> or
            <span class="classname">Zend_Gdata_ClientLogin</span> classes.
        </p>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.gdata.html">Zend_Gdata</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.gdata.authsub.html">Authenticating with AuthSub</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.gdata.html">Zend_Gdata</a></li>
  <li class="active"><a href="zend.gdata.introduction.html">Introduction</a></li>
  <li><a href="zend.gdata.authsub.html">Authenticating with AuthSub</a></li>
  <li><a href="zend.gdata.books.html">Using the Book Search Data API</a></li>
  <li><a href="zend.gdata.clientlogin.html">Authenticating with ClientLogin</a></li>
  <li><a href="zend.gdata.calendar.html">Using Google Calendar</a></li>
  <li><a href="zend.gdata.docs.html">Using Google Documents List Data API</a></li>
  <li><a href="zend.gdata.health.html">Using Google Health</a></li>
  <li><a href="zend.gdata.spreadsheets.html">Using Google Spreadsheets</a></li>
  <li><a href="zend.gdata.gapps.html">Using Google Apps Provisioning</a></li>
  <li><a href="zend.gdata.gbase.html">Using Google Base</a></li>
  <li><a href="zend.gdata.photos.html">Using Picasa Web Albums</a></li>
  <li><a href="zend.gdata.youtube.html">Using the YouTube Data API</a></li>
  <li><a href="zend.gdata.exception.html">Catching Gdata Exceptions</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>